package com.zzh.ribbon.consumer;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 *
 * @author zhengzihong
 * @version 1.0.0
 * @date 2018/12/29
 * @Description
 */
@SpringBootApplication
@EnableEurekaClient
public class RibbionApplication {


    public static void main(String[] args) {
        SpringApplication.run(RibbionApplication.class,args);

    }

    /**
     * 解决RestTemplate 找不到的问题，应该把restTemplate注册SpringBoot容器中@bean
     * 如果使用rest 方式以别名调用进行依赖ribbo 负载均衡器@LoadBalanced
     * @LoadBalanced 就能让这个RestTemplate在请求时拥有客户端负载均衡的能力
     *
     *
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate getRestTemplate(){
        return new RestTemplate();
    }
}
